package common

import (
	"context"
	"git.mycaigou.com/gfyx/common/rpc_client"
	"git.mycaigou.com/gfyx/micro-gfyx-mp-api/infrastructure/common/constants"
	pb "git.mycaigou.com/gfyx/micro-gfyx-mp-api/proto/micro_gfyx_user_service_proto/micro-gfyx-user-service"
)

type miniProgramRepo struct{}

func NewMiniProgramRepository() MiniProgramRepositoryIface {
	return &miniProgramRepo{}
}

func (r *miniProgramRepo) GetQrCodeInfoById(ctx context.Context, request *pb.GetQrCodeInfoByIdRequest) (*pb.GetQrCodeInfoByIdResponse, error) {
	conn, ctx, err := rpc_client.GetClientConn(ctx, constants.MICRO_GFYX_USER_SERVICE)
	if err != nil {
		return nil, err
	}
	defer func() {
		_ = conn.Close()
	}()
	client := pb.NewMiniProgramServiceClient(conn)
	return client.GetQrCodeInfoById(ctx, request)
}
